<?php

namespace app\admin\service\log;

use app\admin\service\BaseService;
use app\common\constant\OperateLogFieldMap;
use app\common\model\common\OperateLog;

class OperateLogService extends BaseService
{
    /**
     * 获取操作记录列表
     * @param string $category 业务类别
     * @param int $data_id 业务类别对应的数据id
     * @return array
     */
    public static function getList(string $category, int $data_id)
    {
        $field_map = self::getFieldMap($category);
        $operate_log = OperateLog::getOperateLog($category, $data_id, $field_map);
        return $operate_log;
    }

    /**
     * 获取指定业务类别的字段映射
     * @param string $category
     * @return mixed
     */
    public static function getFieldMap(string $category)
    {
        $field_map_class = OperateLogFieldMap::$field_map_class[$category];
        return $field_map_class::getMapData();
    }
}
